#include "StdAfx.h"
#include "Entity.h"
#include "Utils.h"

Entity::Entity(void)
{
}


Entity::~Entity(void)
{
}

long Entity::getStartMs(long frameRate)
{
	return (double)(this->startFrame) * (double)1000 / (double)frameRate ;
}

long Entity::getEndMs(long frameRate)
{
	return (double)(this->endFrame) * (double)1000 / (double)frameRate ;
}

CString Entity::getStartTimeString()
{
	CString tmp;
	tmp.Format(L"%02ld:%02ld:%02ld,%03ld",getStartHour(),getStartMin(),getStartSec(),getStartFrame());
	return tmp;
}
CString Entity::getEndTimeString()
{
	CString tmp;
	tmp.Format(L"%02ld:%02ld:%02ld,%03ld",getEndHour(),getEndMin(),getEndSec(),getEndFrame());
	return tmp;
}

void Entity::setStartTimeString(CString hour,CString min,CString sec,CString frame)
{
	this->startHour = _ttol(hour);
	this->startMin =  _ttol(min);
	this->startSec =  _ttol(sec);
	this->startFrame =  _ttol(frame);
}
void Entity::setEndTimeString(CString hour,CString min,CString sec,CString frame)
{
	this->endHour = _ttol(hour);
	this->endMin =  _ttol(min);
	this->endSec =  _ttol(sec);
	this->endFrame =  _ttol(frame);
}

bool Entity::operator==(const Entity& entity)
{
	if(0 == this->id.Compare(entity.id)){
		return true;
	}
	return false;
}
long Entity::getStartHour()
{
	return this->startHour;
}

long Entity::getStartMin()
{
	return this->startMin;
}

long Entity::getStartSec()
{
	return this->startSec;
}

long Entity::getEndHour()
{
	return this->endHour;
}
long Entity::getEndMin()
{
	return this->endMin;
}
long Entity::getEndSec()
{
	return this->endSec;
}

CString Entity::getStartTimeStringExport(long frameRate)
{
	CString tmp;
	tmp.Format(L"%02ld:%02ld:%02ld,%03ld",getStartHour(),getStartMin(),getStartSec(),getStartMs(frameRate));
	return tmp;
}

CString Entity::getEndTimeStringExport(long frameRate)
{
	CString tmp;
	tmp.Format(L"%02ld:%02ld:%02ld,%03ld",getEndHour(),getEndMin(),getEndSec(),getEndMs(frameRate));
	return tmp;
}

long Entity::getStartFrame()
{
	return this->startFrame;
}

long Entity::getEndFrame()
{
	return this->endFrame;
}